package com.caigou.controller.front;

import com.caigou.bean.cms.entity.ArticleKeyword;
import com.caigou.bean.cms.param.ArticleDynamicParam;
import com.caigou.bean.cms.param.ArticleTdkParam;
import com.caigou.bean.cms.param.LabelArticleParam;
import com.caigou.bean.vo.ChannelTdkVO;
import com.caigou.bean.vo.KeyValueVO;
import com.caigou.pojo.ArticleList;
import com.caigou.service.ArticleService;
import com.caigou.util.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/front")
public class FrontArticleKeyWordController {
    @Resource
    private ArticleService articleService;// 新闻Service1



    @GetMapping("/article/keyword/{articleId}")  //是否需要加分页
    public Result<List<ArticleList>> findArticleByKeywordId(@PathVariable("articleId") Integer articleId) {
        return articleService.findArticleByKeywordId(articleId);
    }

    /**
     * 根据关键词查询文章
     * @param
     * @return
     */
    @PostMapping("/keyword/dynamic")
    public Result<PageInfo<ArticleList>> findArticleDynamic(@RequestBody ArticleDynamicParam param) {
        return articleService.findArticleByParam(param);
    }

    /**
     * 根据关键词查询文章
     * @param
     * @return
     */
    @PostMapping("/keyword/dynamic/tdk")
    public Result<ChannelTdkVO> findArticleDynamicTdk(@RequestBody ArticleTdkParam param) {
        return articleService.findArticleDynamicTdk(param);
    }


    /**
     * 根据文章标签查询文章列表
     * @param
     * @return
     */
    @PostMapping("/label/articles")
    public Result<PageInfo<ArticleList>> findLabelArticle(@RequestBody LabelArticleParam param) {
        return articleService.findLabelArticle(param);
    }

    /**
     * 查询文章标签列表
     * @param
     * @return
     */
    @PostMapping("/label/list")
    public Result<List<KeyValueVO>> findLabelArticle() {
        return articleService.findAllArticleLabel();
    }

}
